import DrugStatusEnum from "@/enums/DrugStatusEnum";
import { search } from '/src/api/pharmacy/drug'
import { search as drugTypeSearch } from '/src/api/drug/drugType'
import { search as drugUnitSearch } from '/src/api/drug/drugUnit'
import { search as drugDecoctionSearch } from '/src/api/drug/drugDecoction'


/**
 * @param label 表头
 * @param prop 字段名
 * @param isSearch 是否筛选项
 * @type {[{isSearch: boolean, prop: string, label: string},{isSearch: boolean, prop: string, label: string},{isSearch: boolean, prop: string, label: string},{isSearch: boolean, prop: string, label: string, enum: {0: string, 1: string, 2: string}}]}
 */
const tableColumn = [{
  label: "ID",
  prop: "drug_code",
  isSearch: false,
  isTable: true
}, {
  label: "药品类型",
  prop: "drug_type",
  isForm: true,
  isSearch: true,
  formType: "select",
  required: true,
  multiple: true,
  asyncSelDataApi: drugTypeSearch,
  asyncSelData: []
},  {
  label: "药品名称",
  prop: "name",
  isTable: true,
  isForm: true,
  isSearch: true,
  formType: "input",
  required: true,
  min:0,
  max: 50
}, {
  label: "拼音全拼",
  prop: "pinyin",
  isForm: true,
  formType: "input",
  required: true,
  min:0,
  max: 50
}, {
  label: "拼音码",
  prop: "pinyin_abbr",
  isTable: true,
  isForm: true,
  formType: "input",
  multiple: true,
  required: true,
  min:0,
  max: 200,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药品类型",
  prop: "drug_type_name",
  isTable: true
}, {
  label: "药品别名",
  prop: "alias",
  isTable: true,
  isForm: true,
  formType: "input",
  min:0,
  max: 200,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药品别名全拼",
  prop: "alias_spelling",
  isForm: true,
  formType: "input",
  required: true,
  min:0,
  max: 500,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "别名拼音码",
  prop: "pinyin_alias",
  isTable: true,
  isForm: true,
  formType: "input",
  min:0,
  max: 200,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药品状态",
  prop: "status",
  isTable: true,
  isSearch: true,
  formType: "radio",
  defaultValue: 0,
  enum: DrugStatusEnum
}, {
  label: "默认特殊煎煮",
  prop: "drug_decoction_id",
  isForm: true,
  formType: "select",
  asyncSelDataApi: drugDecoctionSearch,
  asyncSelData: []
}, {
  label: "基础单位",
  prop: "unit_id",
  isTable: true,
  isForm: true,
  formType: "select",
  required: true,
  asyncSelDataApi: drugUnitSearch,
  asyncSelData: []
},{
  label: "最大用量",
  prop: "max_use",
  isForm: true,
  formType: "number",
  min: 1,
  max: 1000,
  tips: "g"
},{
  label: "最小用量",
  prop: "min_use",
  isForm: true,
  formType: "number",
  min: 1,
  max: 1000,
  tips: "g"
}, {
  label: "是否毒麻药",
  prop: "is_toxic",
  isForm: true,
  formType: "switch",
},{
  label: "相似药品",
  prop: "similar_drug",
  isForm: true,
  formType: "select_remote",
  selectRemoteKey: "name",
  multiple: true,
  selectRemoteOptions: { },
  asyncSelDataApi: search,
  asyncSelData: []
}, {
  label: "禁忌病种",
  prop: "taboo_diseases",
  isForm: true,
  formType: "input",
  min:0,
  max: 500,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "创建时间",
  prop: "created_at",
  isTable: true,
}, {
  label: "创建人",
  prop: "created_name",
  isTable: true,
}, {
  label: "修改时间",
  prop: "updated_at",
  isTable: true,
}, {
  label: "修改人",
  prop: "updated_name",
  isTable: true,
}, {
  label: "备注",
  prop: "remark",
  isForm: true,
  formType: "textarea",
  min: 0,
  max: 500
}]
const tableConfig = {
  buttons: ["view", "edit", "status", "batchStatus"],
  statusText: ["上架", "下架"],
  isBatchId: true
}
const pageConfig= {
  small: false,
  disabled: false,
  background: false,
}

export { tableColumn, tableConfig, pageConfig };
